package com.jackeysun.app_widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import com.jackeysun.app_widget.databinding.LayoutIconNodeBinding;
import com.jackeysun.widget.tree.model.TreeNode;


/**
 * Created by Bogdan Melnychuk on 2/12/15.
 */
public class IconTreeItemHolder extends TreeNode.BaseNodeViewHolder<IconTreeItemHolder.IconTreeItem> {

    public IconTreeItemHolder(Context context) {
        super(context);
    }

    @Override
    public View createNodeView(final TreeNode node, IconTreeItem value) {
        final LayoutInflater inflater = LayoutInflater.from(context);
//        final View view = inflater.inflate(R.layout.layout_icon_node, null, false);
        LayoutIconNodeBinding mBinding = LayoutIconNodeBinding.inflate(inflater, null, false);
        mBinding.nodeValue.setText(value.text);
        if (node.isLeaf()){
            mBinding.arrowIcon.setVisibility(View.GONE);
        }
//        mBinding.arrowIcon.setOnClickListener(view -> tView.toggleNode(node));
        return mBinding.getRoot();
    }

//    @Override
//    public void toggle(boolean active) {
////        arrowView.setIconText(context.getResources().getString(active ? R.string.ic_keyboard_arrow_down : R.string.ic_keyboard_arrow_right));
//    }

    public static class IconTreeItem {
        public int icon;
        public String text;

        public IconTreeItem(int id, String text) {
            this.icon = id;
            this.text = text;
        }
    }
}
